﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Design;

namespace ProgNetComponentsDx.Shortcut.Design
{
    public class ShortcutProviderDesigner : ComponentDesigner
    {
        public override DesignerVerbCollection Verbs
        {
            get
            {
                DesignerVerbCollection list = new DesignerVerbCollection();
                list.Add(new DesignerVerb("Set Custom Shortcut For All Empty Controls", new EventHandler(SetCustomShortCut)));
                return list;
            }
        }

        private void SetCustomShortCut(object sender, EventArgs e)
        {
            ShortcutProvider p = Component as ShortcutProvider;
            if (p != null)
            {
                p.BeginInit();
                
                foreach (var kvp in p.AllObjects)
                {
                    if (!kvp.Value.IsCustomShortcut && kvp.Value.ShortCutId.IsNull())
                    {
                        kvp.Value.SetPropertyValueWithPropertyDescriptor("IsCustomShortcut", true);
                    }
                }
                p.EndInit();
            }

        }
    }
}
